/**
 * Created by denh on 16/5/12.
 */
$(function(){
    initData = get_init_data();
    if (initData.is_on == 1) {
        $("#status_key1").text("已开启");
        $("#op_key1").text("关闭");
    } else {
        $("#status_key1").text("已关闭");
        $("#op_key1").text("开启");
    }

    $("#op_key1").click(function(){
        if (!confirm("确定吗？")) {
            return;
        }
        if (initData.is_on == 1) {
            value = 0;
            msg = '已关闭';
        } else {
            value = 1;
            msg = '已开启';
        }
        $.post('index.php',{'m':'system_config', 'a': 'index_post', 'key':'key1', 'value': value},function(data){
            data = eval('(' + data + ')');
            if (data.result == 0) {
                $("#status_key1").text(msg);
                location.reload();
            } else {
                alert('操作失败');
            }
        });
    });
});